//
//  CGQxiugaimimaTableViewCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/4/20.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit

class CGQxiugaimimaTableViewCell: SYBaseCell {

    var bgView: UIView = {
        let v = UIView()
        v.backgroundColor = .white
        return v
    }()
    let tipText: UILabel = {
        let v = UILabel()
        v.text = "原始密码"
        v.font = 15.autoBoldFontSize()
        v.textColor = UIColor(hex: 0x333333)
        return v
    }()
 
    let nameTf: UITextField = {
        let v:UITextField = UITextField()
        v.font = 15.autoFontSize()
        v.placeholder = "请输入原始密码"
        v.isSecureTextEntry = true
        v.textAlignment = .left
        return v
    }()
    
    var lv: UIView = {
        let v = UIView()
        v.backgroundColor = UIColor(hex: 0xEBEBEB)
        return v
    }()
//    
//    
    public func configureView(row: Int) {

        if row == 0 {
          
            tipText.text = "原始密码"
            nameTf.placeholder = "请输入原始密码"
        }
       else if row == 1 {
          
            tipText.text = "新密码"
            nameTf.placeholder = "请输入新密码"
        }
        else if row == 2 {
          
            tipText.text = "确认密码"
            nameTf.placeholder = "请输入确认密码"
        }
        
        
        //结束编辑响应
        nameTf.rx.controlEvent([.editingDidEnd]) //状态可以组合
            .asObservable()
            .subscribe(onNext: { _ in
                print("结束编辑编辑内容!")
                self.passParamsClosure?(self.nameTf.text as Any)
                
            }).disposed(by: disposeBag)
    }
        
    
    override func initViews() {
    
        self.backgroundColor = UIColor(hex: 0xF7F7F7)
        bgView.layer.cornerRadius = 5
        
        self.contentView.addSubview(bgView)
        self.bgView.addSubview(tipText)
        self.bgView.addSubview(nameTf)
        self.bgView.addSubview(lv)
        
        bgView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10.autoWidth())
            make.right.equalToSuperview().offset(-10.autoWidth())
            make.height.equalTo(85.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.bottom.equalToSuperview().offset(-10.autoWidth())
        }
        
        tipText.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(0.autoWidth())
            make.right.equalToSuperview().offset(-21.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
        }
        
        lv.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.right.equalToSuperview().offset(-21.autoWidth())
            make.height.equalTo(0.5)
            make.left.equalToSuperview().offset(10.autoWidth())
        }
        nameTf.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(41.autoWidth())
            make.right.equalToSuperview().offset(-21.autoWidth())
            make.left.equalToSuperview().offset(10.autoWidth())
            make.bottom.equalToSuperview()
        }
    }
}
